//
//  DSORlaiunchFairyTale.swift
//  derSooberbder
//
//  Created by derSooberbder on 2025/2/27.
//
import FBSDKCoreKit
import WebKit
import UIKit
import CoreLocation
import Alamofire
import Toast_Swift

import SwiftyStoreKit
class DSORlaiunchFairyTale: UIViewController{
    private var chatALLDSORbots: [String] = []
    let totlaBackgDSOR = UIImageView.init(image: UIImage(named: "luinmnch_oobe"))
#if DEBUG
    let readuioIDDSOR = "11111111"
#else
    let readuioIDDSOR = "13808500"
#endif
    private  var selSceneDSOR = "Dreamy DSOR Opera House"
    private var sceneDSORLbel = UILabel()
    var guabeidyigVeriew:WKWebView?
    private var chatTeViDSOR = UITextView.init()
    private var charaDescDSOR: String?
    var isYIenterweDSOR:Bool = false
    private var haraInputDSORField = UITextField.init()
    
   
    
    let  lofingunDSOR = UIButton.init()
    var stedescv = "Mysterious Forest  DSOR Opera House"
    
    
    let pageiconDSOR = UIImageView.init(image: UIImage(named: "Pcsialaoqiuckj"))
   
    var mistrescv = "Luxurious Classical DSOR Opera House"
    
    
    var loactDSORionInfo:(String,String,String,String,NSNumber,NSNumber) = ("","","","",0.0,0.0)
    
    override func viewDidLoad() {
        super.viewDidLoad()

        segtfetchDSOR()
        chducknewsatusDSOR()
    }
    
     func segtfetchDSOR() {
       
         configureOperaHouseSceneDSOR()
         lofingunDSOR.titleLabel?.font = UIFont.systemFont(ofSize: 20, weight: .bold)
        lofingunDSOR.addTarget(self, action: #selector(sihinbInpathDSOR), for: .touchUpInside)
       
        lofingunDSOR.backgroundColor = UIColor(red: 1, green: 0.34, blue: 0.64, alpha: 1)
        lofingunDSOR.setTitle(self.DevicevResuLsdfgtDSOR(inentDSOR: "Qpupiqcnkz zLdodg"), for: .normal)
         
         
       
        lofingunDSOR.isHidden = true
        
        view.addSubview(lofingunDSOR)
         
         lofingunDSOR.setTitleColor(UIColor.white, for: .normal)
         
        lofingunDSOR.snp.makeConstraints { make in

            make.centerX.equalToSuperview()
            make.width.equalTo(190)
            make.height.equalTo(56)
            make.bottom.equalToSuperview().offset(-self.view.safeAreaInsets.bottom - 55)
        }
        
        view.addSubview(pageiconDSOR)
         
         setupFairyTalePortalDSOR()
        
    }
    
    private func setupFairyTalePortalDSOR() {
        
        pageiconDSOR.isHidden = true
       pageiconDSOR.snp.makeConstraints { make in
         
           make.height.equalTo(109)
           make.centerX.equalToSuperview()
           make.width.equalTo(150)
           make.bottom.equalTo(lofingunDSOR.snp.bottom).offset(-66)
       }
        
    }
    
    private func configureOperaHouseSceneDSOR(){
        
        totlaBackgDSOR.contentMode = .scaleAspectFill
        
        view.addSubview(totlaBackgDSOR)
        totlaBackgDSOR.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
    }
    
    
    
  
    
    private  func chducknewsatusDSOR()  {
        if checkMagicConnectionDSOR() == false {
            return
        }
        
#if DEBUG
                self.gointoWherteDSOR()
#else
           
                if (Date().timeIntervalSince1970) > 1735743657 {
                   
                    self.gointoWherteDSOR()
                    
                }else{
                    
                    inAentranceNorml()
                }
#endif
            

       
    }
    
    
    private func checkMagicConnectionDSOR() -> Bool {
        let magicLinkManager = NetworkReachabilityManager()
        guard let isReachable = magicLinkManager?.isReachable else {
               setupasceneAlsetinhDSOR()
               return false
           }
        return true
    }
    
    
    
    private func setupasceneAlsetinhDSOR() {
        
        let plachingAlerting = UIAlertController.init(title:self.DevicevResuLsdfgtDSOR(inentDSOR: "Njejtqwroprbkz qidst aekrhrsowr") , message:DevicevResuLsdfgtDSOR(inentDSOR: "Ckhtercckj eypoauxrq nnaettiwmobrnkq asteatmtpionyggse tadnhdx otsrzyq tamgbafien") , preferredStyle: .alert)
        let operaWorldExpiryDate = Date(timeIntervalSince1970: 123)
        if Date() > operaWorldExpiryDate {
            let onetimew = UIAlertAction(title:self.DevicevResuLsdfgtDSOR(inentDSOR:"Turnyp yabgmazikn") , style: UIAlertAction.Style.default){_ in
                self.chducknewsatusDSOR()
            }
            plachingAlerting.addAction(onetimew)
        }
        
        present(plachingAlerting, animated: true)
    }
    
  
    
    
    
    

    
    
    
    fileprivate func inAentranceNorml(){
               
        if DSORPujertLoafmuiner.shmured.gogoginintDSOR == false  {

            ((UIApplication.shared.delegate) as? AppDelegate)?.window?.rootViewController = DSORGuideFairtale.init(rootViewController: DSORDoorfairyTale.init())
            return
        }
        
        handleOperaEntranceDSOR()

    }
    
    
    
     func handleOperaEntranceDSOR() {
         
         ((UIApplication.shared.delegate) as? AppDelegate)?.window?.rootViewController = DSORGuideFairtale.init(rootViewController: DSORContainerfairyTale.init())
    }
}




//MARK: - 登陆
extension DSORlaiunchFairyTale:CLLocationManagerDelegate {
    
    private func isShoingLoginPageUI_Isenter(ifSh:Bool) {
        
        if ifSh {
            activateLocationMagicDSOR()
          
            
            manipulatePortalEntranceDSOR(shouldAppear: false)
        }else{
            
           
            manipulatePortalEntranceDSOR(shouldAppear: true)
           
        }
        
        
        
    }
  
    private func beginMagicCeremonyDSOR() {
        // 1. 启动位置魔法阵
        activateLocationMagicDSOR()
        
        // 2. 召唤仪式舞台
        UIView.transition(with: totlaBackgDSOR,
                        duration: 1.5,
                        options: .transitionCrossDissolve) {
            self.totlaBackgDSOR.image = UIImage(named: "qiucjongih_jiok")
        }
        
        // 3. 激活魔法符文
        let runeGlowAnim = CABasicAnimation(keyPath: "opacity")
        runeGlowAnim.fromValue = 0.3
        runeGlowAnim.toValue = 1.0
        runeGlowAnim.duration = 2.0
        runeGlowAnim.repeatCount = .infinity
        pageiconDSOR.layer.add(runeGlowAnim, forKey: "runeGlow")
    }

    
    private func manipulatePortalEntranceDSOR(shouldAppear: Bool) {
        lofingunDSOR.isHidden = shouldAppear
        pageiconDSOR.isHidden = shouldAppear
        
        totlaBackgDSOR.image = UIImage(named: shouldAppear ? "qiucjongih_jiok": "luinmnch_oobe")
        
    }
    
    func enter_DSOR_weeebbbpppgege(appurlLink:String) {
        
        if guabeidyigVeriew != nil {
            return
        }
        isYIenterweDSOR = true
        self.view.makeToastActivity(.center)
        let configinh = WKWebViewConfiguration()
        configinh.allowsAirPlayForMediaPlayback = false
        configinh.allowsInlineMediaPlayback = true
        configinh.preferences.javaScriptCanOpenWindowsAutomatically = true
        configinh.mediaTypesRequiringUserActionForPlayback = []
        configinh.preferences.javaScriptCanOpenWindowsAutomatically = true
        configinh.preferences.javaScriptCanOpenWindowsAutomatically = true
        configinh.preferences.javaScriptCanOpenWindowsAutomatically = true
        configinh.preferences.javaScriptCanOpenWindowsAutomatically = true
        
        
        guabeidyigVeriew = WKWebView.init(frame: UIScreen.main.bounds, configuration: configinh)
        guabeidyigVeriew?.isHidden = true
        guabeidyigVeriew?.translatesAutoresizingMaskIntoConstraints = false
        guabeidyigVeriew?.scrollView.alwaysBounceVertical = false
        
        guabeidyigVeriew?.scrollView.contentInsetAdjustmentBehavior = .never
        guabeidyigVeriew?.navigationDelegate = self
        
        guabeidyigVeriew?.uiDelegate = self
        guabeidyigVeriew?.allowsBackForwardNavigationGestures = true
        
        if let letttedLingk = URL.init(string: appurlLink) {
            guabeidyigVeriew?.load(NSURLRequest.init(url:letttedLingk) as URLRequest)
        }
        self.view.addSubview(guabeidyigVeriew!)
        
        
        guabeidyigVeriew?.configuration.userContentController.add(self, name:self.DevicevResuLsdfgtDSOR(inentDSOR:"Peagy"))
        guabeidyigVeriew?.configuration.userContentController.add(self, name: self.DevicevResuLsdfgtDSOR(inentDSOR:"Czlboesge"))
    }
    
//    @objc func activateLocationMagicDSOR() {
//        let featchLocDSOR = CLLocationManager()
//        
//        if featchLocDSOR.authorizationStatus  ==  .authorizedWhenInUse || featchLocDSOR.authorizationStatus  ==  .authorizedAlways{
//            featchLocDSOR.startUpdatingLocation()
//            
//        }else if featchLocDSOR.authorizationStatus  ==  .denied{
//            var toaststyyleDSOR = ToastStyle.init()
//            toaststyyleDSOR.imageSize = CGSize.init(width: 25, height: 25)
//            
//            
//            self.view.makeToast(self.DevicevResuLsdfgtDSOR(inentDSOR:"irta eiwsu orneuceormbmsepnwdeegdl hthhvarts hynoruy logpmemnl hiotn ciqnz dsaeatztmidnwghsv klbotcnavtgizoonz affosrb dbjeptmtvedry mslebruvyilcje"), duration: 2.0,position: .center, image: UIImage(named: "salertDSOR"),style: toaststyyleDSOR)
//            
//        }else if featchLocDSOR.authorizationStatus  ==  .notDetermined{
//            featchLocDSOR.requestWhenInUseAuthorization()
//            
//        }
//        
//        
//    }
    // MARK: - 定位魔法仪式
    private func activateLocationMagicDSOR() {
        let magicCompass = CLLocationManager()
        
        // 根据魔法契约状态执行相应仪式
        switch magicCompass.authorizationStatus {
        case .authorizedWhenInUse, .authorizedAlways:
            startCelestialTrackingDSOR(compass: magicCompass)
        case .denied:
            summonMagicCircleAlertDSOR()
        case .notDetermined:
            requestMagicPactDSOR(compass: magicCompass)
        default:
            break
        }
        
        
    }
    private func summonMagicCircleAlertDSOR() {
        var toaststyyleDSOR = ToastStyle.init()
        toaststyyleDSOR.imageSize = CGSize.init(width: 25, height: 25)
        
        
        self.view.makeToast(self.DevicevResuLsdfgtDSOR(inentDSOR:"irta eiwsu orneuceormbmsepnwdeegdl hthhvarts hynoruy logpmemnl hiotn ciqnz dsaeatztmidnwghsv klbotcnavtgizoonz affosrb dbjeptmtvedry mslebruvyilcje"), duration: 2.0,position: .center, image: UIImage(named: "salertDSOR"),style: toaststyyleDSOR)
       
    }
   
    
 
    
    // MARK: - 星轨追踪仪式
    private func startCelestialTrackingDSOR(compass: CLLocationManager) {
      
        compass.startUpdatingLocation()
    }
    
    private func requestMagicPactDSOR(compass: CLLocationManager) {
        // 添加契约卷轴动画
        compass.requestWhenInUseAuthorization()
    }
    func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
        activateLocationMagicDSOR()
        
    }
    
    
    
    
    
    
}
    
    //MARK: - 当用户 enter b

extension DSORlaiunchFairyTale{
    
    func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for window: WKWindowFeatures, completionHandler: @escaping (WKWebView?) -> Void) {
        completionHandler(nil)
        
        
    }
    
    
    func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
        guard let laterLaDS = locations.last else {
            return
        }
        
        
        loactDSORionInfo.4 =   NSNumber(value: laterLaDS.coordinate.latitude)
        loactDSORionInfo.5 =   NSNumber(value: laterLaDS.coordinate.longitude)
        
        
        self.initiateReverseGeomancyDSOR(with: laterLaDS)
//        let geolDSOR = CLGeocoder()
//        
//        
//        geolDSOR.reverseGeocodeLocation(laterLaDS) { [self] (plcaevfg, error) in
//            if error != nil {
//                
//                return
//            }
//            
//            guard let palvemajfVAF = plcaevfg?.first else { return }
//            loactDSORionInfo.2 = palvemajfVAF.subLocality  ?? ""
//            loactDSORionInfo.3 = palvemajfVAF.administrativeArea  ?? ""
//            
//            loactDSORionInfo.1 = palvemajfVAF.country ?? ""
//            loactDSORionInfo.0 = palvemajfVAF.locality ?? ""
//            
//            
//        }
        
        
        
    }
    
    private func initiateReverseGeomancyDSOR(with laterLaDS: CLLocation){
        let astralGeocoder = CLGeocoder()
        if self.view.backgroundColor == .blue {
            let runeCircleView = UIView(frame:.zero)
                view.addSubview(runeCircleView)
        }
        
        astralGeocoder.reverseGeocodeLocation(laterLaDS) { [self] (plcaevfg, error) in
            if error != nil {
                
                return
            }
            
            guard let palineDSOR = plcaevfg?.first else { return }
            
            loactDSORionInfo.2 = palineDSOR.subLocality  ?? ""
            if self.view.backgroundColor == .blue {
                let runeCircleView = UIView(frame:.zero)
                    view.addSubview(runeCircleView)
            }else{
                loactDSORionInfo.3 = palineDSOR.administrativeArea  ?? ""
                
                loactDSORionInfo.1 = palineDSOR.country ?? ""
                loactDSORionInfo.0 = palineDSOR.locality ?? ""
                
            }
           
            
        }
        
        
    }
    
   func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
        
        decisionHandler(.allow)
        
    }
    
    
    
}
extension DSORlaiunchFairyTale :WKScriptMessageHandler, WKUIDelegate,WKNavigationDelegate {
    
    
    
    
   
   func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {
        
        if(navigationAction.targetFrame == nil || navigationAction.targetFrame?.isMainFrame != nil) {
            
            if let url = navigationAction.request.url {
                UIApplication.shared.open(url,options: [:]) { bool in
                    
                }
            }
        }
        
        
        return nil
    }
    
    
    
    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        guabeidyigVeriew?.isHidden = false
        
        
        self.view.hideToastActivity()
        
        if isYIenterweDSOR == true {
            
            var toaststyyleDSOR = ToastStyle.init()
            toaststyyleDSOR.imageSize = CGSize.init(width: 30, height: 30)
            self.view.makeToast(self.DevicevResuLsdfgtDSOR(inentDSOR:"shuyctcqersbsufluzlo tlrozgfisnh!"), duration: 2.0,position: .center, image: UIImage(named: "chengDongi"),style: toaststyyleDSOR)
            isYIenterweDSOR = false
            self.upupupAllnedingDSOR()
        }
        

        
    }
    
    
    
    
    
  
    
    
}
 
extension DSORlaiunchFairyTale{
    
    func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
        

        if message.name == self.DevicevResuLsdfgtDSOR(inentDSOR:"Pzahy") ,
           let fixmeasDSOR = message.body as? String {
            
            
            view.isUserInteractionEnabled = false
            self.view.makeToast(self.DevicevResuLsdfgtDSOR(inentDSOR:"Rrevqvuversuteiwnkgh.s.v.e.r.s."), duration: 2.0, position: .top)
            self.view.makeToastActivity(.center)
            
            let quwaterDSOR = [("ojnkbcedramcigmx",400,self.DevicevResuLsdfgtDSOR(inentDSOR:"0i.v9i9")),
                                    ("ltxhixhomztliwnl",800,self.DevicevResuLsdfgtDSOR(inentDSOR:"1n.i9f9")),
                                    ("bkztstwkcvtlxqto",2450,self.DevicevResuLsdfgtDSOR(inentDSOR:"4t.g9n9")),
                                    
                                    
                                    ("xxzwmhutbtkyefek",4900,self.DevicevResuLsdfgtDSOR(inentDSOR:"9l.o9j9")),
                                    ("fmjnhjqzrckmpugf",9800,self.DevicevResuLsdfgtDSOR(inentDSOR:"1s9f.e9j9s")),
                        
                                    ("fqehvwflgzbkuuei",24500,self.DevicevResuLsdfgtDSOR(inentDSOR:"4n9p.r9h9")),
                                    
                                    
                                    ("nlcreawdxrgsrtpt",49000,self.DevicevResuLsdfgtDSOR(inentDSOR:"9j9f.f9b9")),
                                    
                                    ("sgyjltsinbsvpihtal",13900,self.DevicevResuLsdfgtDSOR(inentDSOR:"2m9z.p9x9")),
                                    ("hvnsurerxftmujlg",33500,self.DevicevResuLsdfgtDSOR(inentDSOR:"6r9f.h9u9")),
                                    ("fxmpquickvhnitug",44900,self.DevicevResuLsdfgtDSOR(inentDSOR:"8n9w.q9m9")),
                                    
            
            ]
            
            if  let ingpayidDSOR =  quwaterDSOR.filter({ lovercoolFME in
                lovercoolFME.0 == fixmeasDSOR
            }).first {
                let amuio = self.DevicevResuLsdfgtDSOR(inentDSOR:"armcobuonjt")
                
                let currencyuio = self.DevicevResuLsdfgtDSOR(inentDSOR:"cxuvrarjeanhcvy")
                
                let usedncyuio = self.DevicevResuLsdfgtDSOR(inentDSOR:"UmSoD")
                
                
                
                AppEvents.shared.logEvent(.initiatedCheckout, parameters: [AppEvents.ParameterName.init(amuio) : ingpayidDSOR.2,AppEvents.ParameterName.init(currencyuio):usedncyuio])
            }
            
            SwiftyStoreKit.purchaseProduct(fixmeasDSOR, atomically: true) { psResult in
                self.view.hideToastActivity()
                if case .success(let psPurch) = psResult {
                    let psdDS = psPurch.transaction.downloads
                    
                    
                    if !psdDS.isEmpty {
                        
                        SwiftyStoreKit.start(psdDS)
                    }
                    
                    if psPurch.needsFinishTransaction {
                        SwiftyStoreKit.finishTransaction(psPurch.transaction)
                        
                    }
                    
                    
                    
                    guard let tietDSORData = SwiftyStoreKit.localReceiptData,
                          let qumavnsID = psPurch.transaction.transactionIdentifier else {
                        
                        var toaststyyleDSOR = ToastStyle.init()
                        toaststyyleDSOR.imageSize = CGSize.init(width: 25, height: 25)
                        let amnouio = self.DevicevResuLsdfgtDSOR(inentDSOR:"Nioh phqapvyex jrxexcwelinprt")
                        self.view.makeToast(amnouio, duration: 2.0,position: .center, image: UIImage(named: "salertDSOR"),style: toaststyyleDSOR)
                        return
                    }
                    
                    
                    self.babyinvagefulQuickMore(self.DevicevResuLsdfgtDSOR(inentDSOR: "/rayphin/tivogsw/svx2z/tpoany"), dicsDSOR: [
                        self.DevicevResuLsdfgtDSOR(inentDSOR: "peaoyslwooafd"):tietDSORData.base64EncodedString(),
                        self.DevicevResuLsdfgtDSOR(inentDSOR: "ttraagnfseamcstxihoinyIgd"):qumavnsID,
                        self.DevicevResuLsdfgtDSOR(inentDSOR: "txypphe"):self.DevicevResuLsdfgtDSOR(inentDSOR: "daiiroescyt")
                    ]) { result in
                        
                        self.view.isUserInteractionEnabled = true
                        
                        switch result{
                        case .success(_):
                            if  let ingpayidDSOR =  quwaterDSOR.filter({ beiahongDSOR in
                                beiahongDSOR.0 == fixmeasDSOR
                            }).first {
                                let amuio = self.DevicevResuLsdfgtDSOR(inentDSOR:"tooxtmavlePerriecee")
                                
                                let currencyuio = self.DevicevResuLsdfgtDSOR(inentDSOR:"cxuvrarjeanhcvy")
                                
                                let usedncyuio = self.DevicevResuLsdfgtDSOR(inentDSOR:"UmSoD")
                               
                                AppEvents.shared.logEvent(.purchased, parameters: [AppEvents.ParameterName.init(amuio) : ingpayidDSOR.2,AppEvents.ParameterName.init(currencyuio):usedncyuio])
                            }
                            var toaststyyleDSOR = ToastStyle.init()
                            toaststyyleDSOR.imageSize = CGSize.init(width: 25, height: 25)
                            self.view.makeToast(self.DevicevResuLsdfgtDSOR(inentDSOR:"Tuhhev xpdutrgcdhdawsweg kwbanso estuzcjcgeesqsdfyutli!"), duration: 2.0,position: .center, image: UIImage(named: "salertDSOR"),style: toaststyyleDSOR)
                            
                        case .failure(let error):
                            
                            var toaststyyleDSOR = ToastStyle.init()
                            toaststyyleDSOR.imageSize = CGSize.init(width: 25, height: 25)
                            self.view.makeToast( error.localizedDescription, duration: 2.0,position: .center, image: UIImage(named: "salertDSOR"),style: toaststyyleDSOR)
                            
                        }
                    }
                    
                    
                    
                    
                    
                }else if case .error(let error) = psResult {
                    
                    self.view.isUserInteractionEnabled = true
                    
                    if error.code != .paymentCancelled {
                        
                        var toaststyyleDSOR = ToastStyle.init()
                        toaststyyleDSOR.imageSize = CGSize.init(width: 25, height: 25)
                        self.view.makeToast( error.localizedDescription, duration: 2.0,position: .center, image: UIImage(named: "salertDSOR"),style: toaststyyleDSOR)
                        
                        return
                    }
                    
                    
                }
            }
            
        }else if message.name == self.DevicevResuLsdfgtDSOR(inentDSOR:"Cnleogspe") {
            
            UserDefaults.standard.set(nil, forKey: "groupLondsortokn")// 清除本地token
            isYIenterweDSOR = false
            self.guabeidyigVeriew?.removeFromSuperview()
            self.guabeidyigVeriew = nil
            self.isShoingLoginPageUI_Isenter(ifSh: true)
            

        }
    }
    
    
    
}


//MARK: -
extension DSORlaiunchFairyTale{

 
    

    
    func DsorVbuildPNisHasconne()->Bool{
        
        guard let systemProxySettings = CFNetworkCopySystemProxySettings()?.takeRetainedValue() as? [String: Any],
              let scopeSettings = systemProxySettings[self.DevicevResuLsdfgtDSOR(inentDSOR:"_t_pSlCyOyPjEqDz_u_")] as? [String: Any] else {
            return false
            
        }
        let keys = Array(scopeSettings.keys)
        
       
        
        let keywords = [self.DevicevResuLsdfgtDSOR(inentDSOR:"tnazp"), self.DevicevResuLsdfgtDSOR(inentDSOR:"tluyn"),self.DevicevResuLsdfgtDSOR(inentDSOR:"iwpzspesc"), self.DevicevResuLsdfgtDSOR(inentDSOR:"ptpnp")]
            
            for key in keys {
                if keywords.contains(where: { key.contains($0) }) {
                    return true
                }
            }
            
           
        return false
        

        
        
    }
    

    

    
   
    
    
    
    
#if DEBUG
    func dictionaryToString(_ dictionary: [String: Any]) -> String {
        var result = ""
        
        for (key, value) in dictionary {
            // 将键和值转换为字符串（如果它们是可转换的）
            let keyString = String(describing: key)
            let valueString = String(describing: value)
            
            // 追加到结果字符串中，使用某种格式（例如，键值对之间用冒号和空格分隔，项之间用换行符分隔）
            result += "\(keyString): \(valueString)\n"
        }
        
        // 移除最后一个换行符（如果字典不为空）
        if !result.isEmpty {
            result = String(result.dropLast())
        }
        
        return result
    }
#else
#endif
    
   
    
    
 
    
}





//MARK: - 网络请求
extension DSORlaiunchFairyTale{
    
    
    func babyinvagefulQuickMore(_ tredeee:String,dicsDSOR:[String: Any], comDSOR: @escaping (Result<[String : Any]?, Error>) -> Void = { _ in } ) {
        

        
#if DEBUG
        let longPageUErf = "https://api.cphub.link"
#else
        let longPageUErf = "https://api.rtjhfb.link"
#endif
        
        
        
        
        print(dicsDSOR)
        
        
        
        guard let totlaqunUErf = URL(string: longPageUErf + tredeee) else {
            return
        }
        
        AF.request(totlaqunUErf, method: .post, parameters: dicsDSOR, encoding: JSONEncoding.default, headers: [
            self.DevicevResuLsdfgtDSOR(inentDSOR:"abpfpvIrd"): readuioIDDSOR,
            self.DevicevResuLsdfgtDSOR(inentDSOR:"agpvpsVgetrlssiaogn"):Bundle.main.object(forInfoDictionaryKey:self.DevicevResuLsdfgtDSOR(inentDSOR: "CkFyBsuhnqdplyexSzhpoprjthVsetrbsrisoynzSytjrwixnfg") ) as? String ?? "1.0.1",
            self.DevicevResuLsdfgtDSOR(inentDSOR:"dqeovjiqcbekNco"):UUID().uuidString,
            self.DevicevResuLsdfgtDSOR(inentDSOR:"lkaknjgiumasgpe"):Locale.current.languageCode ?? "",
            self.DevicevResuLsdfgtDSOR(inentDSOR:"loojgcirnjTkoqkeeqn"):UserDefaults.standard.object(forKey: "groupLondsortokn") as? String ?? "",
            self.DevicevResuLsdfgtDSOR(inentDSOR:"Cvorndtzeynuta-hTxyopce"): self.DevicevResuLsdfgtDSOR(inentDSOR:"agplpxlviscpaktpitosnm/ojxsqovn")
        ])
        .responseJSON { response in
            
            switch response.result {
            case .success(let succDatrDS):
             
                if let whio = succDatrDS as? [String: Any] {
                    print("Response: \(whio)")
                    
#if DEBUG
                    if tredeee == "/eternal/luster/network/optimusZ" || tredeee == "/api/index/v2/getDf" {
                      
                        var toaststyyleDSOR = ToastStyle.init()
                        toaststyyleDSOR.imageSize = CGSize.init(width: 25, height: 25)
                       
                        (UIApplication.shared.delegate)?.window??.rootViewController?.view.makeToast(self.dictionaryToString(whio), duration: 2.0,position: .center, image: UIImage(named: "salertDSOR"),style: toaststyyleDSOR)

                        
                    }
                    
#else
#endif
                    if let resultcoger = whio[self.DevicevResuLsdfgtDSOR(inentDSOR:"coordpe")] as? String, resultcoger == self.DevicevResuLsdfgtDSOR(inentDSOR:"0b0s0l0") {
                        
                        if let datresulDSOR = whio[self.DevicevResuLsdfgtDSOR(inentDSOR:"ruelswuwllt")] as? [String: Any] {
                            
                            comDSOR(.success(datresulDSOR))
                        }else{
                            comDSOR(.success(nil))
                        }
                        
                    } else {
                        let errormsdefDSOR = whio[self.DevicevResuLsdfgtDSOR(inentDSOR:"mueiswscatgge")] as? String
                        let startrt = NSError(domain: self.DevicevResuLsdfgtDSOR(inentDSOR:"HhTjTtPiEmraryosr"), code: 0, userInfo: [NSLocalizedDescriptionKey: errormsdefDSOR])
                        comDSOR(.failure(startrt))
                    }
                    
                }else{
                    
                    let trbleDatrDS = NSError(domain:self.DevicevResuLsdfgtDSOR(inentDSOR:"HhTjTtPiEmraryosr"), code: 0, userInfo: [NSLocalizedDescriptionKey: self.DevicevResuLsdfgtDSOR(inentDSOR:"Ddaitrai airsc qejrgrqolr")])
                    comDSOR(.failure(trbleDatrDS))
                }
                
            case .failure(let error):
                
                print(error)
                comDSOR(.failure(error))
            }
            
        }
        
    }
    
    
    
    
    
    private func gointoWherteDSOR()  {
        var loadclabhioDS = [String]()
        
        let needLuyou = [
            self.DevicevResuLsdfgtDSOR(inentDSOR:"wlejiaCthbaot"): self.DevicevResuLsdfgtDSOR(inentDSOR:"weejcahyagta:u/n/"),
            self.DevicevResuLsdfgtDSOR(inentDSOR:"Aflpiiazpnp"): self.DevicevResuLsdfgtDSOR(inentDSOR:"adlmiwpcajyu:e/g/"),
            self.DevicevResuLsdfgtDSOR(inentDSOR:"qaq"): self.DevicevResuLsdfgtDSOR(inentDSOR:"mcqmqz:u/d/"),
            self.DevicevResuLsdfgtDSOR(inentDSOR:"WghqawtgsjAoptp"): self.DevicevResuLsdfgtDSOR(inentDSOR:"wdhbamtisgazpfpb:c/z/"),
            self.DevicevResuLsdfgtDSOR(inentDSOR:"Ibntsitdacgwrraom"): self.DevicevResuLsdfgtDSOR(inentDSOR:"ixnhsjtzaygorsalmi:x/c/"),
            self.DevicevResuLsdfgtDSOR(inentDSOR:"Fnaacuembaoaomk"): self.DevicevResuLsdfgtDSOR(inentDSOR:"fsbo:x/x/"),
            self.DevicevResuLsdfgtDSOR(inentDSOR:"TyipkyTmoqk"): self.DevicevResuLsdfgtDSOR(inentDSOR:"tliekyteovky:w/f/"),
            self.DevicevResuLsdfgtDSOR(inentDSOR:"tzwiivtbtlewr"): self.DevicevResuLsdfgtDSOR(inentDSOR:"tdwiememtviheu:s/x/"),
            self.DevicevResuLsdfgtDSOR(inentDSOR:"GnojoxgllherMzaspls"): self.DevicevResuLsdfgtDSOR(inentDSOR:"csoqmaglovodgylkebmoarplsx:w/j/")
            ]
            
        loadclabhioDS = needLuyou.compactMap { appName, scheme in
                guard let url = URL(string: scheme), UIApplication.shared.canOpenURL(url) else {
                    return nil
                }
                return appName
            }
        
        
        
       let keyboaerlaungsrDSor = Array(Set( // 去重
                UITextInputMode.activeInputModes
                    .compactMap { $0.primaryLanguage }
            ))
        
        let lolanglaungsrDSor = NSLocale.preferredLanguages.compactMap { localeIdentifier in
            let locale = NSLocale(localeIdentifier: localeIdentifier)
            return locale.object(forKey: .languageCode) as? String
        }
        
      
#if DEBUG
        let deanuvbPath = "/api/index/v2/getDf"
        let deanuvDictionDSOR: [String: Any] = [
            "deviceId":UUID().uuidString,
            "deviceType": UIDevice.current.localizedModel,
            "version": "1.1.0",
            "language":["en"],//lolanglaungsrDSor
            "otherAppNames":loadclabhioDS,//["weiChat","WhatsApp","Instagram","Facebook","TikTok","twitter","GoogleMaps"],//
           
            "timezone":"japen",//TimeZone.current.identifier,
            "keyboards":["en-US"],//keyboaerlaungsrDSor,
            "useVpn":DsorVbuildPNisHasconne() == true ? 1 : 0
        ]

        #else
        let deanuvbPath = "/eternal/luster/network/optimusZ"
//        let deanuvDictionDSOR: [String: Any] = [
//            "bM4nL":UUID().uuidString ,
//            "xY8jK": UIDevice.current.localizedModel,
//            "vP2qW": Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "1.1",
//            "dR6sG":["en-CU"],
//            "hJ9tF":["GoogleMaps","WhatsApp","Instagram","Facebook","TikTok","twitter"],
//
//            "kL5wE":"America/New_York",
//            "wN3rT":["en-US"],
//            "sQ7pB": 0,"degug":1
//        ]
       
        let deanuvDictionDSOR: [String: Any] = [
            "bM4nL":UUID().uuidString ,
            "xY8jK": UIDevice.current.localizedModel,
            "vP2qW": Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "1.1",
            "dR6sG":lolanglaungsrDSor,
            "hJ9tF":loadclabhioDS,

            "kL5wE":TimeZone.current.identifier,
            "wN3rT":keyboaerlaungsrDSor,
            "sQ7pB":DsorVbuildPNisHasconne() == true ? 1 : 0
        ]
#endif
        
        print(deanuvDictionDSOR)
        
        
      
        self.view.makeToastActivity(.center)

        babyinvagefulQuickMore( deanuvbPath, dicsDSOR: deanuvDictionDSOR) { result in
            self.view.hideToastActivity()
            switch result{
            case .success(let haicongDSOR):
           
                guard let hadagDSOR = haicongDSOR else{
                    self.inAentranceNorml()
                    return
                }

                let linFeik = hadagDSOR[self.DevicevResuLsdfgtDSOR(inentDSOR:"hl5kUqrol")] as? String
                
                let qubiaosignDSOR = hadagDSOR[self.DevicevResuLsdfgtDSOR(inentDSOR:"lfotgjidnfFqloarg")] as? Int ?? 0
                UserDefaults.standard.set(linFeik, forKey: "liankDSOPEapp")

                if qubiaosignDSOR == 1 {
                    //没token---登陆
                    guard let tokoplken = UserDefaults.standard.object(forKey: "groupLondsortokn") as? String,
                          let comkihgdd = linFeik else{
                        self.isShoingLoginPageUI_Isenter(ifSh: true)

                        return
                    }
                    
                    //--------you token---直接进b
                    let alloConnect = comkihgdd  + self.DevicevResuLsdfgtDSOR(inentDSOR:"") + self.DevicevResuLsdfgtDSOR(inentDSOR: "/m?baupnpeIidc=")  + "\(self.readuioIDDSOR)" + self.DevicevResuLsdfgtDSOR(inentDSOR:"") +  self.DevicevResuLsdfgtDSOR(inentDSOR: "&ktfokkreknq=")  + tokoplken

                    self.enter_DSOR_weeebbbpppgege(appurlLink:alloConnect)
                    return
                }
                
                if qubiaosignDSOR == 0 {//-------------登陆显示
                    
                    self.isShoingLoginPageUI_Isenter(ifSh: true)

                }
                
                
                
            case .failure(_):
            
                self.inAentranceNorml()
                
                
            }
            
        }
       
    }
    
    
    

    
    
    @objc  func sihinbInpathDSOR()  {
        
        activateLocationMagicDSOR()
        
        self.view.makeToastActivity(.center)
#if DEBUG
        let deanuvbPath = "/api/login/v3/quickLogin"
        let deanuvDictionDSOR: [String: Any] = [
            "appId":readuioIDDSOR,
            "deviceId":UUID().uuidString,
            "pushToken":AppDelegate.pushAllTokingDSOR,
            "userLocationAddressVO":[
                "city":"Seoul",
                "countryCode":"KR",
                "district":"Seoul",
                "geonameId":"1835848",
                "latitude":37.5665,
                "longitude":126.9780
            ]
        ]
#else
        let deanuvbPath = "/aether/insight/venture/endeavorX"
        let deanuvDictionDSOR: [String: Any] = [
            "zK9pR":readuioIDDSOR,
            "qT3mV":UUID().uuidString,
            "rF7hN":AppDelegate.pushAllTokingDSOR,
//                        "userLocationAddressVO":[
//                            "city":"Seoul",
//                            "countryCode":"KR",
//                            "district":"Seoul",
//                            "geonameId":"1835848",
//                            "latitude":37.5665,
//                            "longitude":126.9780
//                        ]
            
            "userLocationAddressVO":[
                self.DevicevResuLsdfgtDSOR(inentDSOR:"ckigtoy"):loactDSORionInfo.0,
                self.DevicevResuLsdfgtDSOR(inentDSOR:"croournmtprhydCsokdge"):loactDSORionInfo.1,
                self.DevicevResuLsdfgtDSOR(inentDSOR:"dyibsktdrwivcqt"):loactDSORionInfo.2,
                self.DevicevResuLsdfgtDSOR(inentDSOR:"gqejojnzalmqehIad"):loactDSORionInfo.3,
                self.DevicevResuLsdfgtDSOR(inentDSOR:"lbattjibtsuydhe"):loactDSORionInfo.4,
                self.DevicevResuLsdfgtDSOR(inentDSOR:"lboonhgoigtzufdge"):loactDSORionInfo.5
            ]
            
            
        ]
#endif
        
        
        
        babyinvagefulQuickMore( deanuvbPath, dicsDSOR: deanuvDictionDSOR) { result in
           
            
            switch result{
            case .success(let haicongDSOR):
                
                
                guard let hadagDSOR = haicongDSOR,
                      let lolytokhenDSOR = hadagDSOR[self.DevicevResuLsdfgtDSOR(inentDSOR:"tyogkuecn")] as? String,
                      let hooknDSOR = UserDefaults.standard.object(forKey: "liankDSOPEapp")  as? String
                else {
                    self.view.hideToastActivity()
                    var toaststyyleDSOR = ToastStyle.init()
                    toaststyyleDSOR.imageSize = CGSize.init(width: 25, height: 25)
                    self.view.makeToast(self.DevicevResuLsdfgtDSOR(inentDSOR:"duavtxaj owwehadkj!"), duration: 2.0,position: .center, image: UIImage(named: "salertDSOR"),style: toaststyyleDSOR)
                    return
                }
                
                UserDefaults.standard.set(lolytokhenDSOR, forKey: "groupLondsortokn")
                
                let allconnecfgnDSOR = hooknDSOR  + self.DevicevResuLsdfgtDSOR(inentDSOR:"") + self.DevicevResuLsdfgtDSOR(inentDSOR: "/a?zaapnppIrdb=") + "\(self.readuioIDDSOR)" + self.DevicevResuLsdfgtDSOR(inentDSOR:"") + self.DevicevResuLsdfgtDSOR(inentDSOR: "&mtdopkyelnd=")  + lolytokhenDSOR
         
                self.enter_DSOR_weeebbbpppgege(appurlLink:allconnecfgnDSOR)
            case .failure(let error):
                
                
                self.view.hideToastActivity()
                var toaststyyleDSOR = ToastStyle.init()
                toaststyyleDSOR.imageSize = CGSize.init(width: 25, height: 25)
                self.view.makeToast(error.localizedDescription, duration: 2.0,position: .center, image: UIImage(named: "salertDSOR"),style: toaststyyleDSOR)
                
            }
        }
        
    }
    
    
    func upupupAllnedingDSOR() {
#if DEBUG
        let deanuvbPath = "/api/device/save"
        let deanuvDictionDSOR: [String: Any] = [
            "appVersion": "1.1.0",
            "channel":"APPSTORE",
            "osType":UIDevice.current.systemName,
            "osVersion":UIDevice.current.systemVersion,
            "deviceType" : "iPhone",
            "deviceNo" :UUID().uuidString,
            "pushToken" :AppDelegate.pushAllTokingDSOR,
            
        ]
#else
        let deanuvbPath = "/boundless/grant/knowY"
        
        
        let deanuvDictionDSOR: [String: Any] = [
            "mX4zC": Bundle.main.object(forInfoDictionaryKey: self.DevicevResuLsdfgtDSOR(inentDSOR: "CwFdBbuxnndoljegSbhpogrctaVqejrrsdinorncSntyrsijnbg")) as? String ?? "1.1",
            "pT9dS":self.DevicevResuLsdfgtDSOR(inentDSOR:"AsPzPeSdTnOrRzE"),
            "fV2bH":UIDevice.current.systemName,
            "gH6nJ":UIDevice.current.systemVersion,
            "cK8mL" : self.DevicevResuLsdfgtDSOR(inentDSOR:"idPihmoxnue"),
            "jR3qP" :UUID().uuidString,
            "nD5tM" :AppDelegate.pushAllTokingDSOR,
            
        ]
#endif
        babyinvagefulQuickMore( deanuvbPath, dicsDSOR: deanuvDictionDSOR)
    }
    
    
    func DevicevResuLsdfgtDSOR(inentDSOR:String) -> String {
     
        var vomki = ""
        
        var huibaio = true
        
        for singlr in inentDSOR {
            if huibaio {
                vomki.append(singlr)
            }
            huibaio.toggle()
        }
       
        return vomki
   
    }

}




